package com.ruibang.glass.portal.controller;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruibang.glass.portal.entity.Notice;
import com.ruibang.glass.portal.entity.SysCity;
import com.ruibang.glass.portal.service.SysCityService;
import com.ruibang.glass.portal.service.SysProvinceService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import javax.servlet.http.HttpServletResponse;


@RestController
@RequestMapping("/api/sys/cityAndProvince")
@Slf4j
@Api(tags = "省份城市")
public class ProvinceAndCityController {
    @Autowired
    private SysProvinceService sysProvinceService;
    @Autowired
    private SysCityService sysCityService;


    @GetMapping("/getProvinceList")
    @ApiOperation(value = "获取省份下拉", response = ResultBody.class)
    public ResultBody getProvinceList() {
        return ResultBody.success(sysProvinceService.list());
    }

    @GetMapping("/getCityList/{id}")
    @ApiOperation(value = "获取城市下拉", response = ResultBody.class)
    public ResultBody getProvinceList(@PathVariable("id") String id) {
        return ResultBody.success(sysCityService.list(Wrappers.<SysCity>lambdaQuery().select(SysCity::getId,SysCity::getName).eq(SysCity::getProvinceId, id)));
    }


}
